package com.moon.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.moon.entity.Student;
import com.moon.service.StudentService;
import com.moon.utils.BaseController;

@Controller
@RequestMapping("/moon/Student")
public class StudentController extends BaseController {
	@Autowired
	private StudentService studentService;
	@CachePut(cacheNames="cache0")//redis注解
	@RequestMapping("/select")
	@ResponseBody
	public List<Student> selectAll(String depart,String sex,int pageNum,int pageSize) throws InterruptedException{
		//Thread.sleep(3000);
		return 	studentService.selectStudent(depart,sex,pageNum,pageSize);
	}
	@CacheEvict(cacheNames="cache0",allEntries = true)
	@RequestMapping("/del")
	@ResponseBody
	public String delete(Integer id) {
		studentService.deletedata(id);
		//System.out.println("删除成功");
		return "success";
	}
	@RequestMapping("update")
	@ResponseBody
	public String update(Integer id) {
		studentService.updatedata();
		return "success";
	}
}